<?php

namespace App\Services\PolicyUpload;

class RuleService
{

    /**
     * 规则运价默认参数
     * @param $param
     * @return mixed
     */
    public static function platformUpload($param){

        $value= [
            'PolicyCode'                => $param['policy_code'],
            'PolicyStatus'              => env('POLICY_VALID') == 0  ? 'INVALID' : ($param['status'] == 1 ? 'NORMAL':'INVALID'),
            'IsShareFlight'             => !empty($param['IsShareFlight']) ? $param['IsShareFlight'] : 'F',
            'ProductType'               => 1,
            "AirLine"                   => $param['hs_code'],
            "FlightWay"                 => 'S',

            'GoEffectDate'              => $param['date'],
            "GoExpiryDate"              => $param['date'],
            "SaleEffectDate"            => date('Y-m-d'),
            "SaleExpiryDate"            => $param['date'],
            'SaleFlightList' => [
                [
                    'DPort'                     => $param['depart_city_code'],
                    'APort'                     => $param['arrived_city_code'],
                    'FlightFrom'                => $param['flight_code'],
                    'FlightTo'                  => $param['flight_code'],
                    'IsCanSale'                 => 'T'
                ]
            ],
            "RulePriceList"             => [
                [
                    "SubClass"          => $param['cabin_code'],
                    "RcID"              => $param['platform'] == 20 ? "12410623" : '12730236',
                    "NumCarryRule"      => 'RoundTens',
                    "Commision"         => 0,
                    'PriceRule'         => 'PriceRuleZeroEnum',
                    "SubtractPrice"     => $param["one_dec_price"],
                    "BidType"           => 0,
                    "BiddingSpace"      => $param['compare_price'],
                    'InventoryType'     => $param['InventoryType'],
                    "Inventory"         => $param['seat']
                ]
            ],
        ];

        return $value;
    }
}